'use strict';

module.exports = app => {
  const { STRING, BIGINT, DATE, BOOLEAN } = app.Sequelize;

  return app.model.define('SystemRoleMenu', {
    id: {
      type: BIGINT,
      primaryKey: true,
      autoIncrement: true,
      comment: '自增编号'
    },
    roleId: {
      type: BIGINT,
      allowNull: false,
      field: 'role_id',
      comment: '角色ID'
    },
    menuId: {
      type: BIGINT,
      allowNull: false,
      field: 'menu_id',
      comment: '菜单ID'
    },
    creator: {
      type: STRING(64),
      allowNull: true,
      defaultValue: '',
      comment: '创建者'
    },
    createTime: {
      type: DATE,
      allowNull: false,
      defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
      field: 'create_time',
      comment: '创建时间'
    },
    updater: {
      type: STRING(64),
      allowNull: true,
      defaultValue: '',
      comment: '更新者'
    },
    updateTime: {
      type: DATE,
      allowNull: false,
      defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
      field: 'update_time',
      comment: '更新时间'
    },
    deleted: {
      type: BOOLEAN,
      allowNull: false,
      defaultValue: false,
      comment: '是否删除'
    }
  }, {
    tableName: 'system_role_menu',
    timestamps: false, // 不使用Sequelize的默认时间戳字段
  });
};
